//
//  RootViewController.m
//  AppFrameWork
//
//  Created by Le Anh Tai on 4/25/13.
//  Copyright (c) 2013 Le Anh Tai. All rights reserved.
//

#import "RootViewController_iPhone.h"
#import "Reachability.h"
#import "AdGADBanner.h"
#import "AdiAdBanner.h"
#import "HomeViewController_iPhone.h"

#define INDEX_GOLD_VIEW_CONTROLLER 0
#define INDEX_RATES_VIEW_CONTROLLER 1
//#define INDEX_CHART_VIEW_CONTROLLER 2

@interface RootViewController_iPhone ()

@end

@implementation RootViewController_iPhone

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        
    }
    
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    _reopenAdInterval = 20;
    _adsMix = [[AdsMix alloc] initWithType:AdMixTypeWeight];
    
    AdItem *item2 = [[AdItem alloc] init];
    [item2 configureWithClass:[AdGADBanner class] numberOfAllowFails:1];
    
    [_adsMix configureAds:@[item2]];
    _adsMix.delegate = self;
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
}

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];
    
    [self layoutSubviews];
}

#pragma mark -
- (void)containerViewWillClose:(ContainerBannerView *)view
{
    NSLog(@"Restart ads request after %ds", _reopenAdInterval);
    
    [_adsMix performSelector:@selector(restartRequest) withObject:nil afterDelay:_reopenAdInterval];
}

@end
